﻿using Microsoft.AspNetCore.Http;
using System.Text;

namespace Common
{
    /// <summary>
    /// 获取管理用户信息
    /// </summary>
    public class ManageUser : IUser
    {
        private UserInfo _data;
        public ManageUser(IHttpContextAccessor accessor)
        {
            string sessionValue = accessor.HttpContext.Session.GetString(SystemConstConfig.AuthHeader);
            var sessionJson = AESEncryptHelper.Decode(sessionValue);
            if (!sessionJson.IsNullOrWhiteSpace())
            {
                _data = sessionJson.ToObject<UserInfo>();
            }
        }

        public UserInfo UserInfo
        {
            get
            {
                return _data;
            }
        }
    }
}
